import os
import itchat
import numpy as np
import pandas as pd
from apscheduler.schedulers.blocking import BlockingScheduler


@itchat.msg_register(itchat.content.TEXT, isGroupChat=True)
def reply_msg(msg):
    global data
    chatroom = itchat.search_chatrooms(userName=msg['FromUserName'])
    group_name = chatroom['NickName']
    group_id = chatroom["UserName"]
    message = msg.text
    if chatroom is None:
        return
    if message == "西红柿，我爱你！":
        itchat.send("傻强", toUserName=group_id)


def register_sched():
    sched.add_job(updata_blog_data, 'cron', minute="*/10", second=00)
    sched.start()


def shutdown_sched():
    sched.shutdown()


if __name__ == '__main__':
    sched = BlockingScheduler(timezone='Asia/Shanghai')
    # itchat.auto_login(exitCallback=shutdown_sched)
    itchat.auto_login(exitCallback=shutdown_sched, hotReload=True, statusStorageDir='newInstance.pkl')
    itchat.run(blockThread=False)
    register_sched()
